﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>json格式化及高亮</title>
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
    <meta name="description" content="json,格式化,高亮"/>
    <meta name="keywords" content="json,格式化,高亮"/>
    <script src="jsonFormater.js" type="text/javascript"></script>
    <link href="jsonFormater.css" type="text/css" rel="stylesheet"/>
    <link href="demo.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="HeadersRow">
    <div id="HeaderTitle">JSON formatted and highlighted by <a targe='_blank' href="http://leo108.com/">leo108</a> core code reference <a target="_blank" href='http://tmxk.org/c/json/'>maverick studio</a></div>
    <h3 id="HeaderSubTitle">JSON formatting and highlighting:</h3>
    <textarea id="RawJson">[{"link": "https://www.google.com.pk", "count": [14000, 15000 ], "description": {"sensitive": false, "text": "This contains some awesome text."}, "title": "apples"} ]</textarea>
</div>
<div id="ControlsRow">
    <input type="Button" value="Format Code" id='format'/>
  <span id="TabSizeHolder">
    Indentation
    <select id="TabSize">
        <option value="1">1</option>
        <option value="2" selected>2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
    </select>
  </span>
    <input type="checkbox" id="QuoteKeys" checked='checked' />
    <label for="QuoteKeys">
        Quotation marks
    </label>&nbsp;
      <input type="checkbox" id="CollapsibleView" checked='checked' />
      <label for="CollapsibleView">
          The display control
      </label>
  <span id="CollapsibleViewDetail">
    <a href="javascript:void(0);" id="expandAll">展开</a>
    <a href="javascript:void(0);" id="collapseAll">叠起</a>
    <a href="javascript:void(0);" class="expand" data-level="3">2级</a>
    <a href="javascript:void(0);" class="expand" data-level="4">3级</a>
    <a href="javascript:void(0);" class="expand" data-level="5">4级</a>
    <a href="javascript:void(0);" class="expand" data-level="6">5级</a>
    <a href="javascript:void(0);" class="expand" data-level="7">6级</a>
    <a href="javascript:void(0);" class="expand" data-level="8">7级</a>
    <a href="javascript:void(0);" class="expand" data-level="9">8级</a>
  </span>
</div>
<div id="Canvas" class="Canvas"></div>
<script type="application/javascript">
    (function () {
        var format = function () {
            var options = {
                dom: document.getElementById('Canvas'),
                isCollapsible: document.getElementById('CollapsibleView').checked,
                quoteKeys: document.getElementById('QuoteKeys').checked,
                tabSize: document.getElementById('TabSize').value
            };
            window.jf = new JsonFormatter(options);
            jf.doFormat(document.getElementById('RawJson').value);
        };
        document.getElementById('format').addEventListener('click', function() {
            format();
        });
        document.getElementById('expandAll').addEventListener('click', function() {
            window.jf.expandAll();
        });
        document.getElementById('collapseAll').addEventListener('click', function() {
            window.jf.collapseAll();
        });
        var x = document.querySelectorAll('#TabSize, #CollapsibleView, #QuoteKeys');
        Array.prototype.forEach.call(x, function(el, i) {
            el.addEventListener('change', function () {
                format();
            });
        });
    })();
</script>
</body>
</html>

